#include "bits/stdc++.h"
using namespace std;
int main() {
    int a;
    int stu_num[1010];
    int score[1010];
    cin>>a;
    int sum = 0;
    for (int i = 1; i <= a; ++i) {
        cin>>stu_num[i]>>score[i];
        sum += score[i];
    }
    double average = 1.00 * sum / a;
    for (int i = 1;i <= a;i ++) {
        cout<<stu_num[i]<<" " <<score[i]<<" ";
        if (score[i] - average >= 10.00)
            cout<<"A"<<"\n";
        else if (score[i] - average <= -10.00)
            cout<<"C"<<"\n";
        else
            cout<<"B"<<"\n";
    }
    return 0;
}